import axios from 'axios'

import auth from '@/utils/auth'

const instance = axios.create({
  baseURL: 'http://geek.itheima.net/',
  timeout: 5000
})

instance.interceptors.request.use(config => {
  const token = auth.getToken()
  if (token) config.headers.Authorization = `Bearer ${token}`
  return config
}, err => Promise.reject(err))

export default instance
